package com.tiancheng.trade.commom.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * 支付场景枚举
 *
 * @author supeicheng
 * @date 2024/4/2
 */
@Getter
@AllArgsConstructor
public enum PaySceneEnum implements BaseEnum<String> {

    // app中支付
    APP("app", "app"),
    // 小程序中支付（微信小程序、支付宝小程、云闪付小程序）
    MINIAPP("miniapp", "miniapp"),
    // h5中支付
    H5("H5", "H5"),
    // 微信公众号
    WXAPP("wxapp", "wxapp"),
    // web端支付
    PCWEB("pcweb", "pcweb"),
    // 刷脸支付
    FACESWIPING("face-swiping", "face-swiping"),
    // 扫码支付
    SCAN("scan", "scan"),
    UNION_MINI("union_mini", "union_mini"),
    // 免支付-抵扣
    DEDUCTION("deduction","deduction"),
    ;

    private final String code;
    private final String desc;

    public static  Optional<PaySceneEnum> getByCode(String code){
        return Arrays.stream(PaySceneEnum.values()).filter(c -> c.code.equals(code)).findFirst();
    }
    public static String getDesc(String code) {
        Optional<PaySceneEnum> found = getByCode(code);
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }

    public static List<String> getCodeList(){
        return Arrays.stream(PaySceneEnum.values()).map(PaySceneEnum::getCode).collect(Collectors.toList());
    }

}
